package com.Tool;
import android.app.Activity;
import android.content.Context;
import android.os.Vibrator;
import android.util.Log;
import android.widget.Toast;

import com.unity3d.player.UnityPlayer;

public class Tools {
    public static final String TAG = "MLSDK";
    public static Activity activity = null;
    public static  Vibrator ChacheVb = null;
    public static  Activity getActivity(){
        if(activity==null){
            activity = UnityPlayer.currentActivity;
        }
        return  activity;
    }

    //震动
    public static void Vibrator(long patter,int repeat){
        if(ChacheVb!=null){
            ChacheVb.vibrate(patter);
            return;
        }
        ChacheVb = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
        if(ChacheVb!=null){
            ChacheVb.vibrate(patter);
        }
    }

    public static void ShowToast(String msg,int length){
        Toast.makeText(getActivity(),msg,length).show();
    }
}